package org.mch.func.file.createfolder;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Insets;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.border.LineBorder;
import javax.swing.border.TitledBorder;

import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
import org.mch.biz.ui.BizEvent;
import org.mch.biz.ui.BizPanel;
import org.mch.swingm.ext.METextChooser;
import org.mch.swingm.ext.METextField;

import javax.swing.JTextArea;

public class ClientPanel extends BizPanel {
	private static final long serialVersionUID = 1L;
	private JPanel panel;
	private JButton btn_execute;
	private METextChooser text_targetfolder;
	private JScrollPane scrollPane;
	private RSyntaxTextArea text_filename;
	private METextField text_createrule;
	private JScrollPane scrollPane_1;
	private JTextArea text_rulelist;
	private JButton btn_preview;

	public ClientPanel() {
		initComponents();
	}

	private void initComponents() {
		setLayout(new BorderLayout(0, 0));
		add(getPanel());
	}

	public JPanel getPanel() {
		if (this.panel == null) {
			this.panel = new JPanel();
			panel.setPreferredSize(new Dimension(200, 10));
			panel.setBorder(new LineBorder(Color.LIGHT_GRAY));
			this.panel.setLayout(null);
			panel.add(getText_targetfolder());
			panel.add(getBtn_execute());
			panel.add(getScrollPane_1());
			panel.add(getText_createrule());
			panel.add(getScrollPane_1_1());
			panel.add(getBtn_preview());
		}
		return this.panel;
	}

	protected BizEvent createEvent() {
		return new ClientEvent(this);
	}

	public JButton getBtn_execute() {
		if (btn_execute == null) {
			btn_execute = new JButton("执行");
			btn_execute.setFont(new Font("宋体", Font.PLAIN, 16));
			btn_execute.setMargin(new Insets(2, 2, 2, 2));
			btn_execute.setBounds(774, 12, 72, 33);
			btn_execute.addMouseListener(getEvent());
		}
		return btn_execute;
	}

	public METextChooser getText_targetfolder() {
		if (text_targetfolder == null) {
			text_targetfolder = new METextChooser("生成文件夹目标目录：");
			text_targetfolder.setBounds(10, 12, 752, 33);
		}
		return text_targetfolder;
	}

	public JScrollPane getScrollPane_1() {
		if (scrollPane == null) {
			scrollPane = new JScrollPane();
			scrollPane.setBorder(new TitledBorder(null, "生成文件夹列表", TitledBorder.LEADING, TitledBorder.TOP, null, null));
			scrollPane.setBounds(396, 126, 450, 476);
			scrollPane.setViewportView(getText_filename());
		}
		return scrollPane;
	}

	public RSyntaxTextArea getText_filename() {
		if (text_filename == null) {
			text_filename = new RSyntaxTextArea();
			text_filename.setFont(new Font("宋体", Font.PLAIN, 13));
			text_filename.setBorder(new LineBorder(Color.LIGHT_GRAY, 2));
		}
		return text_filename;
	}

	public METextField getText_createrule() {
		if (text_createrule == null) {
			text_createrule = new METextField("生成文件夹规则表达式：");
			text_createrule.getComponent().setText("Chrome-{0}");
			text_createrule.setBounds(10, 57, 366, 33);
		}
		return text_createrule;
	}

	public JScrollPane getScrollPane_1_1() {
		if (scrollPane_1 == null) {
			scrollPane_1 = new JScrollPane();
			scrollPane_1.setBorder(new TitledBorder(new LineBorder(new Color(184, 207, 229)), "\u89C4\u5219\u8BBE\u7F6E",
					TitledBorder.LEADING, TitledBorder.TOP, null, null));
			scrollPane_1.setBounds(12, 126, 366, 476);
			scrollPane_1.setViewportView(getText_rulelist());
		}
		return scrollPane_1;
	}

	public JTextArea getText_rulelist() {
		if (text_rulelist == null) {
			text_rulelist = new JTextArea();
			text_rulelist.setFont(new Font("宋体", Font.PLAIN, 13));
			text_rulelist.setText("{0}=39 - 54");
			text_rulelist.setBorder(new LineBorder(new Color(0, 0, 0)));
		}
		return text_rulelist;
	}

	public JButton getBtn_preview() {
		if (btn_preview == null) {
			btn_preview = new JButton("预览");
			btn_preview.setMargin(new Insets(2, 2, 2, 2));
			btn_preview.setFont(new Font("宋体", Font.PLAIN, 16));
			btn_preview.setBounds(396, 57, 72, 33);
			btn_preview.addMouseListener(getEvent());
		}
		return btn_preview;
	}
}